package com.formation.tocea.library.client.ui.manager;

import books.borrowing.bo.IBookBorrowingBo;
import books.borrowing.bo.impl.BookBorrowingBoImpl;

import com.formation.tocea.library.client.listener.ShowAddBookFormListener;
import com.formation.tocea.library.client.ui.list.BookTable;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

public class BookManagerPanel extends VerticalPanel {
	private HorizontalPanel buttonPanel;
	private Button addBookButton;
	private Button removeBookButton;
	private BookTable bookTable;

	public BookManagerPanel() {
		init();
	}

	public void init() {
		setWidth("100%");
		
		buttonPanel = new HorizontalPanel();
		addBookButton = new Button("Ajouter un livre");
		removeBookButton = new Button("Supprimer les livres selectionnés");
		bookTable = new BookTable();
		
		buttonPanel.setSpacing(3);
		addBookButton.addClickHandler(new ShowAddBookFormListener());
		
		buttonPanel.add(addBookButton);
		buttonPanel.add(removeBookButton);
		
		add(buttonPanel);
		add(bookTable);
		
		IBookBorrowingBo bookBorrowingBo = new BookBorrowingBoImpl();
		try {
			bookBorrowingBo.rentBook("armat", "1234567890123");
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}

	public BookTable getBookTable() {
		return bookTable;
	}
}
